<?php
		session_start();
define('TEMPLATES', '../templates/');
define('JS','../js/');
define('CSS','../css/');
define('OBJETOS','../objetos/');
define('NEGOCIOS','../negocio/');
define('EXTENSION','.phtml');
function __autoload($class_name){
  require_once $class_name . '.php';
}
 
Class TransaccionNocheregalo {
	
	var $AdminObj;
	var $generador_xhtml;
	var $vars;
	
	function TransaccionNocheregalo($array_vars){
		$this->AdminObj=new AdminNocheregalo();
		$this->vars=$array_vars;
		$this->generador_xhtml=new GeneradorXHTML();
	}

	function transNewNocheregalo(){
		$Nocheregalo=$this->AdminObj->getNewObject("Nocheregalo",array(Nocheregalo));
		
		$option_estancia=$this->generador_xhtml->getOptions($this->AdminObj->getEstancia());

		
		$this->generador_xhtml->mostrarTpl($Nocheregalo,array("tpl"=>"Nocheregalo"  ,"boton"=>"Guardar Datos","accion"=>"transSetNocheregalo","css"=>"ui.datepicker.css.php","js"=>"Nocheregalo.js,ui.datepicker.js.php,Validator.js","option_estancia"=>$option_estancia),"");
	}
	
	function transSetNocheregalo(){
		$this->vars['id_nocheregalo']=$this->AdminObj->getNewID("Nocheregalo","id_nocheregalo");
		$Nocheregalo=$this->AdminObj->getNewObject("Nocheregalo",$this->vars);
		$this->AdminObj->setNocheregalo($Nocheregalo);
		$Nocheregalo=$this->AdminObj->getNocheregalo($this->vars['id_nocheregalo']);
		$Nocheregalo=json_encode($Nocheregalo[0]);
		echo("[".$Nocheregalo."]");
		
	}
	
	function transGetNocheregalo(){
		$Nocheregalo=$this->AdminObj->getNocheregalo($this->vars['id_nocheregalo']);
		$em=json_encode($Nocheregalo[0]);
        echo("[".$em."]");
	}
    function transGetNocheregalo2(){
		$Nocheregalo=$this->AdminObj->getNocheregalo2($this->vars['id_nocheregalo']);
		$em=json_encode($Nocheregalo[0]);
        echo("[".$em."]");
	}
	
	function transUpdateNocheregalo(){
		$Nocheregalo=$this->AdminObj->getNewObject("Nocheregalo",$this->vars);
		$this->AdminObj->updateNocheregalo($Nocheregalo);
		$this->AdminObj->redireccionar("TransaccionNocheregalo.php");	
	}
	
	function transDeleteNocheregalo(){
			$eliminar=split(";",$this->vars["id_nocheregalo"]);
		foreach($eliminar as $k=>$v)
		{
		$this->AdminObj->DeleteNocheregalo($this->AdminObj->getNocheregalosss($v));
		}
		$this->AdminObj->redireccionar("TransaccionNocheregalo.php");
	}
	function transGetNocheregalos()
	{
				$option_estancia=$this->generador_xhtml->getOptions($this->AdminObj->getEstancia());

		$rows=$this->generador_xhtml->generarRowsTable2($this->AdminObj->getNocheregalos(),"button","button","checkbox",false,0,array(0),array(0));
		$this->generador_xhtml->mostrarTpl("",array("tpl"=>"Nocheregalo","boton"=>"Guardar Datos","accion"=>"transSetNocheregalo","css"=>"ui.datepicker.css.php","rows"=>$rows,"js"=>"Nocheregalo.js,ui.datepicker.js.php,Validator.js","option_estancia"=>$option_estancia),"");
	}		
}

if($_GET){
	$vars_trans=array_slice($_GET,1);
//antes no olvidar poner una validador para que nadie pueda ejecutar las funciones
	call_user_func(array(new TransaccionNocheregalo($vars_trans),current($_GET)?current($_GET):"transGetNocheregalos"));
}
else if($_POST){
		$vars_trans=array_slice($_POST,1);
		call_user_func(array(new TransaccionNocheregalo($vars_trans),current($_POST)?current($_POST):"transGetNocheregalos"));
		}
	else	call_user_func(array(new TransaccionNocheregalo(array()),"transGetNocheregalos"));

?>